<?php /* Smarty version Smarty3-RC3, created on 2013-10-10 07:44:02
         compiled from ".\templates\./bullionEntry.tpl" */ ?>
<?php /*%%SmartyHeaderCode:2764452565ac22e9554-80400891%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'c95ae8a12b399379076f82b18ad71d2d3b28027e' => 
    array (
      0 => '.\\templates\\./bullionEntry.tpl',
      1 => 1328336526,
    ),
  ),
  'nocache_hash' => '2764452565ac22e9554-80400891',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<?php if (!is_callable('smarty_function_html_options')) include 'D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\sil1\include\Smarty\libs\plugins\function.html_options.php';
if (!is_callable('smarty_function_html_select_date')) include 'D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\sil1\include\Smarty\libs\plugins\function.html_select_date.php';
?><?php $_template = new Smarty_Internal_Template("header.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript">
	
$(document).ready(function()
{
  $(".delete").live('click', function(event) 
  {
    $(this).parent().remove();
    setTotAmount();
  });
});

function addNewRow()
{
  $('#billBook tr:last').after('<tr class="itemRow"><td align="center"><input type="text" name="particulars[]" \/><\/td><td align="center"><input type="text" name="kg[]" class="kg" onChange="setAmount(this)"\/><\/td><td align="center"><input type="text" name="bhav[]" class="bhav" onChange="setAmount(this)"\/><\/td><td align="center"><input type="text" name="cramount[]" class="cramount" onChange="setTotAmount(this)"\/><\/td><td align="center"><input type="text" name="crfine[]" class="crfine" onChange="setTotAmount(this)" \/><\/td><td align="center"><input type="text" name="dramount[]" class="dramount" onChange="setTotAmount(this)" \/><\/td><td align="center"><a href="javascript:addNewRow();"><?php echo $_smarty_tpl->getVariable('l_add')->value;?>
<\/a><\/td><td class="delete"><?php echo $_smarty_tpl->getVariable('l_remove')->value;?>
<\/td><\/tr>');
}		

function setAmount(txtObj)
{
  var row = $(txtObj).parents('.itemRow');
  var price = parseFloat(row.find('.kg').val().replace("$","")) * parseFloat(row.find('.bhav').val()/1000);
  isNaN(price) ? row.find('.cramount').val("") : row.find('.cramount').val(price);
  setTotAmount();
}

function setTotAmount()
{
  var totalkg       = 0;
  var totalcramount = 0;
  var totaldramount = 0;
  var totcrFine = 0;
  
  $('.kg').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totalkg += Number(price);
  });
  
  $('.cramount').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totalcramount += Number(price);
  });
  
  $('.dramount').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totaldramount += Number(price);
  });
  
 $('.crfine').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totcrFine += Number(price);
  });

  $('#totkg').val(totalkg);
  $('#totcramount').val(totalcramount);
  $('#totdramount').val(totaldramount);
  $('#totcrFine').val(totcrFine);
}
function getOldAmount()
{
  if(document.form1.party.value > 0)
	{
	  $.ajax({
	  type:"POST",
	  url:'getOldAmountBullion.php',
	  data:
	  {
	    partyId : document.form1.party.value
	  },
	  success: function(response)
	  {
	  	var temp = response.split(",");
	  	prevPartyFine = temp[0];
	  	prevPartyAmount = temp[1];
	  	$('#partyFine').val(prevPartyFine);
	  	$('#partyAmount').val(prevPartyAmount);
	  }
	  });
	}
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="isEdit" value="<?php echo $_smarty_tpl->getVariable('isEdit')->value;?>
" />
<input type="hidden" name="bullionmasterid" value="<?php echo $_smarty_tpl->getVariable('bullionmasterid')->value;?>
" />

<center><h4>Bullion Entry</h4></center>
<?php if ($_smarty_tpl->getVariable('msg')->value!=''){?><center><span style="color:#FF0000"><b><?php echo $_smarty_tpl->getVariable('msg')->value;?>
</b></span></center><?php }?>
<div class="contentDiv">
  <table border="1  " id="billBook" align="center" width="100%" cellpadding="0">
  <tr>
    <td colspan="5" class="table1">
      <?php echo $_smarty_tpl->getVariable('l_partySelect')->value;?>
 :
      <select name="party" onChange="getOldAmount();">
        <?php echo smarty_function_html_options(array('values'=>$_smarty_tpl->getVariable('party')->value['partyId'],'output'=>$_smarty_tpl->getVariable('party')->value['bullionPartyName'],'selected'=>$_smarty_tpl->getVariable('partyId')->value),$_smarty_tpl->smarty,$_smarty_tpl);?>

      </select>
    </td>
    <td colspan="6" class="table1">
      <?php echo $_smarty_tpl->getVariable('l_bulliondate')->value;?>
 :
      <?php echo smarty_function_html_select_date(array('prefix'=>"curDate",'start_year'=>"-2",'end_year'=>"+1",'field_order'=>"DMY",'day_value_format'=>"%02d",'time'=>$_smarty_tpl->getVariable('bulliondate')->value),$_smarty_tpl->smarty,$_smarty_tpl);?>

    </td>
  </tr>
  <tr class="table1">
    <th><?php echo $_smarty_tpl->getVariable('l_particulars')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_kg')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_bhav')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_cramount')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_crfine')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_dramount')->value;?>
</th>
    <th colspan="2">&nbsp;</th>
  </tr>
  <?php if ($_smarty_tpl->getVariable('isEdit')->value==1){?>
    <?php unset($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]);
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['name'] = "sec";
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop'] = is_array($_loop=count($_smarty_tpl->getVariable('bullionArray')->value)) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show'] = true;
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'] = 1;
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop']-1;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show']) {
    $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop'];
    if ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'] == 0)
        $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show'] = false;
} else
    $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'] = 0;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show']):

            for ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] = 1;
                 $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'];
                 $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration']++):
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['first']      = ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] == 1);
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['last']       = ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total']);
?>
      <tr class="itemRow">
        <td align="center"><input type="text" name="particulars[]" value="<?php echo $_smarty_tpl->getVariable('bullionArray')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['particulars'];?>
" /></td>
        <td align="center"><input type="text" name="kg[]" class="kg" onChange="setAmount(this)"  value="<?php echo $_smarty_tpl->getVariable('bullionArray')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['kg'];?>
" /></td>
        <td align="center"><input type="text" name="bhav[]" class="bhav" onChange="setAmount(this)" value="<?php echo $_smarty_tpl->getVariable('bullionArray')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['bhav'];?>
" /></td>
        <td align="center"><input type="text" name="cramount[]" class="cramount" value="<?php echo $_smarty_tpl->getVariable('bullionArray')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['cramount'];?>
"/></td>
        <td align="center"><input type="text" name="crfine[]" class="crfine" onChange="setTotAmount(this)" value="<?php echo $_smarty_tpl->getVariable('bullionArray')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['crfine'];?>
" /></td>
        <td align="center"><input type="text" name="dramount[]" class="dramount" onChange="setTotAmount(this)" value="<?php echo $_smarty_tpl->getVariable('bullionArray')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['dramount'];?>
" /></td>
        <td align="center"><a href="javascript:addNewRow();"><?php echo $_smarty_tpl->getVariable('l_add')->value;?>
</a></td>
        <td class="delete"><?php echo $_smarty_tpl->getVariable('l_remove')->value;?>
</td>
      </tr>
    <?php endfor; endif; ?>
  <?php }?>
  <tr class="itemRow">	
    <td align="center"><input type="text" name="particulars[]" /></td>
    <td align="center"><input type="text" name="kg[]" class="kg" onChange="setAmount(this)"/></td>
    <td align="center"><input type="text" name="bhav[]" class="bhav" onChange="setAmount(this)" /></td>
    <td align="center"><input type="text" name="cramount[]" class="cramount" onChange="setTotAmount(this)"/></td>
    <td align="center"><input type="text" name="crfine[]" class="crfine" onChange="setTotAmount(this)"/></td>
    <td align="center"><input type="text" name="dramount[]" class="dramount"  onChange="setTotAmount(this)" /></td>
    <td align="center"><a href="javascript:addNewRow();"><?php echo $_smarty_tpl->getVariable('l_add')->value;?>
</a></td>
    <td align="center">&nbsp;</td>
  </tr>
  </table>
  
  <table border="1" width="100%">
    <tr class="itemRowTot">
      <th align="right"  width="145px;"><?php echo $_smarty_tpl->getVariable('l_total')->value;?>
</th>
      <th align="center" width="145px;"><input type="text" name="totkg" id="totkg"/></th>
      <th align="right"  width="145px;">&nbsp;</th>
      <th align="center"  width="146px;"><input type="text" name="totcramount" id="totcramount"/></th>
      <th align="center"  width="146px;"><input type="text" name="totcrFine"   id="totcrFine"/></th>
      <th align="right"  width="180px;"><input type="text" name="totdramount" id="totdramount"/></th>
      <th align="right"  width="80px;">&nbsp;</th>
      <th colspan="2"    width="110px;"></th>
    </tr>
  </table>
   <div align="right">
  	 Previous Fine :   <input type ="text" name="Netfine" id="partyFine" onChange="setTotAmount"><br>	
  	 Previous Amount : <input type ="text" name="Netamount" id="partyAmount" onChange="setTotAmount">
   </div>
  <div align="left">
  <?php if ($_smarty_tpl->getVariable('isEdit')->value==1){?>
    <input type="submit" name="billBookAddBtn" value="<?php echo $_smarty_tpl->getVariable('l_save')->value;?>
"/>
  <?php }else{ ?>
    <input type="submit" name="billBookAddBtn" value="<?php echo $_smarty_tpl->getVariable('l_addBillBook')->value;?>
"/>
  <?php }?>
</div>
</form>
<script type="text/javascript">
<?php if ($_smarty_tpl->getVariable('isEdit')->value==1){?>
  setTotAmount();
<?php }?>  
</script>
<?php $_template = new Smarty_Internal_Template("footer.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>